package com.jinsi.service.tang.iml;


import com.jinsi.constant.TangConstant;
import com.jinsi.mapper.tang.CourseReviewMapper;
import com.jinsi.pojo.Comment;
import com.jinsi.service.tang.CourseReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 课程评论
 * @author 唐文博
 * @Date 2022-09-07
 */
@Service
@Transactional
public class CourseReviewServiceImpl implements CourseReviewService {
    @Autowired
    private CourseReviewMapper courseReviewMapper;

    /**
     * 查看课程历史评论人数和次数
     * @return
     */
    @Override
    @Transactional(readOnly = true)
    public int getCourseReview() {
        return courseReviewMapper.getCourseReview(TangConstant.COMMENT_CURRICULUM);
    }

    /**
     * 查看今日课程评论人数和次数
     * @return
     */
    @Override
    @Transactional(readOnly = true)
    public int getCourseToday() {
        return courseReviewMapper.getCourseToday(TangConstant.COMMENT_CURRICULUM);
    }

    /**
     * 查看课程评论列表的成员账号，昵称，所属商品，发言时间，发言内容
     * @return
     */
    @Override
    @Transactional(readOnly = true)
    public List<Comment> getReview() {
        return courseReviewMapper.getReview(TangConstant.COMMENT_CURRICULUM);
    }

    /**
     * 查看正常课程评论列表的成员账号及信息（已通过）
     * @return
     */
    @Override
    @Transactional(readOnly = true)
    public List<Comment> getReviewNormal(Integer status) {
        return courseReviewMapper.getReviewNormal(status,TangConstant.COMMENT_CURRICULUM);
    }

    /**
     * 修改成已拦截状态 //状态 1已通过 2已拦截 3已删除',课程
     * @param id
     * @param status
     */
    @Override
    public void updateReviewBlocked(Integer id, Integer status) {
        courseReviewMapper.updateReviewBlocked(id,status);
    }

}
